package logs

import (
	"log"
	"os"
)

const (
	LOGPATH = "/var/log/mongo.log"
)

func PrintlnFile(logtext string,logger int) {
	logFile,err  := os.OpenFile(LOGPATH,os.O_WRONLY | os.O_CREATE | os.O_APPEND, 0644)
	defer logFile.Close()
    	if err != nil {
        	log.Fatalln("open file '"+LOGPATH+"' error")
    	}
	Logger := "[Info] "
	if logger == 4{
		Logger = "[Warning] "
	}else if logger >= 5{
		Logger = "[Error] "
	}
    	echoLog := log.New(logFile,Logger,log.LstdFlags)
    	echoLog.Println(logtext)
}
